package com.zqc.login.controller;

import com.zqc.login.service.AuthCodeService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/code")
public class CodeController {

    @Reference
    private AuthCodeService authCodeService;

    @GetMapping("/validate/{email}/{code}")
    public Integer validate(
            @PathVariable(value = "email") String email,
            @PathVariable(value = "code") String code) {
        return authCodeService.validate(email, code);
    }

    @GetMapping("/create/{email}")
    public Boolean create(@PathVariable String email) {
        return authCodeService.create(email);
    }
}
